use "HR-appointments.dta", clear
gen noncareerpct = perm_ses_noncareer/(perm_ses_noncareer + perm_ses_career)
gen schedcpct = (perm_excep_schedc + temp_excep_schedc)/total

replace schedcpct = . if agency == "All"
replace noncareerpct = . if agency == "All"

cmp setup


set seed 1384
cmp (schedcpct = c.z_pres_congdist##i.divided || agency: || pres_name:) ///
	(noncareerpct = c.z_pres_congdist##i.divided|| agency: || pres_name:), ///
	ind($cmp_frac $cmp_frac) redraws(23 23) tech(dfp 25 nr 25)
eststo m1

cmp	(schedcpct = c.z_pres_fildist##i.divided || agency: || pres_name:) ///
	(noncareerpct = c.z_pres_fildist##i.divided || agency: || pres_name:), ///
	ind($cmp_frac $cmp_frac) redraws(23 23) tech(dfp 25 nr 25)
eststo m2

cmp (schedcpct = pres_switch partyswitch  start_second_term sameagency ///
	                c.z_pres_congdist##i.divided z_polarization ///
					z_rollcalls prev_exec_pct prev_ses_noncareer_pct_gap central zmecompmedian looming|| agency: || pres_name:) ///
	(noncareerpct = pres_switch partyswitch  start_second_term sameagency ///
                    c.z_pres_congdist##i.divided z_polarization ///
					z_rollcalls prev_exec_pct prev_ses_noncareer_pct_gap central zmecompmedian looming|| agency: || pres_name:), ///
    ind($cmp_frac $cmp_frac) redraws(19 19) tech(dfp 100 nr 10 bfgs 20)  iterate(1000) difficult
eststo m3

cmp (schedcpct = pres_switch partyswitch  start_second_term sameagency ///
	             c.z_pres_fildist##i.divided z_polarization ///
				 z_rollcalls prev_exec_pct prev_ses_noncareer_pct_gap central zmecompmedian looming|| agency: || pres_name:) /// 
	(noncareerpct = pres_switch partyswitch  start_second_term sameagency ///
                    c.z_pres_fildist##i.divided z_polarization ///
					z_rollcalls prev_exec_pct prev_ses_noncareer_pct_gap central zmecompmedian looming|| agency: || pres_name:), ///
	ind($cmp_frac $cmp_frac) redraws(37 37, antithetics) tech(dfp 100 nr 10) iterate(1000) difficult
eststo m4

esttab m1 m2 m3 m4 using "Table-A15.html", ///
    replace label cells(b(star fmt(3)) se(par fmt(3))) stats(chi2 p aic bic ll N, fmt(3 3 3 3 3 0) ///
	labels("Likelihood Ratio Test" "Likelihood Ratio Test p-value" "Akaike Information Criterion" ///
	"Bayesian Information Criterion" "Log Likelihood" "Number of observations")) ///
	style(html) wrap varwidth(95) ///
	mlabels(none) collabels(none) ///
	starlevels(^{*} .1 ^{**} .05 ^{***} 0.01)
